class Solution {
public:
    string destCity(vector<vector<string>>& paths)
    {
        unordered_map<string, string> hash;
        for (int i = 0; i < paths.size(); i++)
            hash[paths[i][0]] = paths[i][1];
        string ans(paths[0][0]);
        while (hash.find(ans) != hash.end()) ans = hash[ans];
        return ans;
    }
};